package com.example.fw;


public class ContactHelper extends HelperBase {
	
	public ContactHelper(ApplicationManager appManager){
		super(appManager);
	}

	public void createContact(Contact contact) {
		initContactCreation();
		fillContactData(contact);
		submitContactCreation();
		
	}

	public void submitContactCreation() {
		manager.getAutoItHelper()
		.click("Save")
		.winWaitAndActivate("AddressBook Portable", "", 5000);
	}

	public void fillContactData(Contact contact) {
		manager.getAutoItHelper()
		.send("TDBEdit12", contact.firstName)
		.send("TDBEdit11", contact.lastName);
	}

	public void initContactCreation() {
		manager.getAutoItHelper()
		.winWaitAndActivate("AddressBook Portable", "", 5000)
		.click("Add")
		.winWaitAndActivate("Add Contact", "", 5000);
	}

	public Contact getFirstContact() {
		manager.getAutoItHelper()
		.click("TListView1")
		.send("{DOWN}{SPACE}")
		.click("Edit")
		.winWaitAndActivate("Update Contact", "", 5000);
		String firstName = manager.getAutoItHelper().getText("TDBEdit12");
		String lastName = manager.getAutoItHelper().getText("TDBEdit11");
		manager.getAutoItHelper().click("Cancel");
		return new Contact().setFirstName(firstName).setLastName(lastName);
	}
}
